package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter@Setter
@JsonIgnoreProperties({"handler","json"})//转json时忽略某些属性
public class Strategy extends BaseDomain{

    /**
     * 0 普通
     * 1 热门
     * -1 禁用
     */
    public static final int STATE_COMMON=0;
    public static final int STATE_HOT=1;
    public static final int STATE_DISABLE=-1;

    //地区
    private Region place;
    //攻略标题
    private String title;
    //副标题
    private String subTitle;
    //封面
    private String coverUrl;
    //状态
    private Integer state;


    //页面状态汉字回显
    public String getStateName() {
        state=0;
        String msg="普通";
        if (state==STATE_HOT) {
            msg="热门";
        }else if (state==STATE_DISABLE){
            msg="禁用";
        }
        return msg;
    }
    /**
     * 增加一个属性 json对象
     * @return
     */
    public String getJson() {
        Map<String,Object> map= new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state", state);
        if(place!=null){
            map.put("placeId",place.id);
            map.put("placeName",place.getName());
        }
        return JSONUtil.toJSONString(map);
    }


}